import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  // { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  {
    path: '/404',
    component: () =>
      import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dataLakeConsole',
    children: [{
      path: 'dataLakeConsole',
      name: '数据概览',
      meta: {
        title: '数据概览',
        icon: 'chart'
      },
      component: () =>
        import('@/views/dataLakeConsole/index')
    }]
  },
  {
    path: '/dataComponent',
    component: Layout,
    redirect: '/dataComponent/dataSouce',
    name: '数据组件',
    meta: {
      title: '数据组件',
      icon: 'component'
    },
    children: [
      {
        path: 'dataSouce',
        name: '数据源状态',
        component: () =>
          import('@/views/dataComponent/dataSouce/index'),
        meta: {
          title: '数据源状态',
          icon: 'table'
        }
      },
      {
        path: 'dataConfigure',
        name: '数据源配置',
        component: () =>
          import('@/views/dataComponent/dataConfigure/index'),
        meta: {
          title: '数据源配置',
          icon: 'tree'
        }
      },
      {
        path: 'dataES',
        name: 'ES集群',
        component: () =>
          import('@/views/dataComponent/dataES/index'),
        meta: {
          title: 'ES集群',
          icon: 'tree'
        }
      },
      {
        path: 'dataHadoop',
        name: 'Hadoop集群',
        component: () =>
          import('@/views/dataComponent/dataHadoop/index'),
        meta: {
          title: 'Hadoop集群',
          icon: 'tree'
        }
      },
      {
        path: 'dataPG',
        name: 'PG数据库',
        component: () =>
          import('@/views/dataComponent/dataPG/index'),
        meta: {
          title: 'PG数据库',
          icon: 'tree'
        }
      },
      {
        path: 'dataDSB',
        name: 'DSB数据服务总线',
        component: () =>
          import('@/views/dataComponent/dataDSB/index'),
        meta: {
          title: 'DSB数据服务总线',
          icon: 'tree'
        }
      }
    ]
  },
  {
    path: '/monitorAssay',
    component: Layout,
    redirect: '/monitorAssay/taskFlow',
    name: '监控分析',
    meta: {
      title: '监控分析',
      icon: 'nested'
    },
    children: [
      {
        path: 'taskFlow',
        name: '任务流程监控',
        component: () =>
          import('@/views/monitorAssay/taskFlow/index'),
        meta: {
          title: '任务流程监控',
          icon: 'table'
        }
      },
      {
        path: 'flowChart',
        name: '任务流程拓扑图',
        hidden: true,
        meta: {
          title: '任务流程拓扑图',
          icon: 'chart',
          path: '/monitorAssay/taskFlow',
          parent: '任务流程监控'
        },
        component: () =>
          import('@/views//monitorAssay/flowChart/index')
      },
      {
        path: 'dataAsset',
        name: '数据资产统计',
        component: () =>
          import('@/views/monitorAssay/dataAsset/index'),
        meta: {
          title: '数据资产统计',
          icon: 'table'
        }
      },
      {
        path: 'serverAction',
        name: '服务运行状态',
        component: () =>
          import('@/views/monitorAssay/serverAction/index'),
        meta: {
          title: '服务运行状态',
          icon: 'table'
        }
      },
      {
        path: 'serverUse',
        name: '服务使用统计',
        component: () =>
          import('@/views/monitorAssay/serverUse/index'),
        meta: {
          title: '服务使用统计',
          icon: 'table'
        }
      }
    ]
  },
  {
    path: '/dataGovernance',
    component: Layout,
    redirect: '/dataGovernance/agencyTask',
    name: '数据治理',
    meta: {
      title: '数据治理',
      icon: 'excel'
    },
    children: [
      {
        path: 'startTask',
        name: '开始任务',
        component: () =>
          import('@/views/dataGovernance/startTask/index'),
        meta: {
          title: '开始任务',
          icon: 'table'
        }
      },
      {
        path: 'agencyTask',
        name: '代办任务',
        component: () =>
          import('@/views/dataGovernance/agencyTask/index'),
        meta: {
          title: '代办任务',
          icon: 'table'
        }
      },
      {
        path: 'myTask',
        name: '我的任务',
        component: () =>
          import('@/views/dataGovernance/myTask/index'),
        meta: {
          title: '我的任务',
          icon: 'table'
        }
      },
      {
        path: 'operationPage',
        name: '操作页面',
        component: () =>
          import('@/views/dataGovernance/operationPage/index'),
        meta: {
          title: '操作页面',
          icon: 'table'
        }
      }
    ]
  },
  {
    path: '/dataPortal',
    component: Layout,
    redirect: '/dataPortal/servicePortal',
    name: '数据门户',
    meta: {
      title: '数据门户',
      icon: 'international'
    },
    children: [
      {
        path: 'servicePortal',
        name: '业务门户',
        component: () =>
          import('@/views/dataPortal/servicePortal/index'),
        meta: {
          title: '业务门户',
          icon: 'table'
        }
      },
      {
        path: 'devPortal',
        name: '开发门户',
        component: () =>
          import('@/views/dataPortal/devPortal/index'),
        meta: {
          title: '开发门户',
          icon: 'table'
        }
      }
    ]
  },

  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
})
